/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * DrawStrategySelectionPanel.java
 *
 * Created on Jul 14, 2010, 10:49:30 PM
 */

package taikai.draws;

import javax.swing.JFrame;
import taikai.TeamsOrPlayers;

/**
 *
 * @author jeffmartin
 */
public abstract class DrawStrategySelectionPanel extends javax.swing.JDialog {
    private final TeamsOrPlayers teamsOrPlayers;
    private final KnockoutDrawStrategy knockoutDrawStrategy1;
    private final RoundRobinDrawStrategy roundRobinDrawStrategy1;

    /** Creates new form DrawStrategySelectionPanel */
    public DrawStrategySelectionPanel(JFrame parent, TeamsOrPlayers teamsOrPlayers) {
        super(parent, ModalityType.APPLICATION_MODAL);
        this.teamsOrPlayers = teamsOrPlayers;
        this.knockoutDrawStrategy1  = new KnockoutDrawStrategy(teamsOrPlayers);
        this.roundRobinDrawStrategy1  = new RoundRobinDrawStrategy(teamsOrPlayers);
        initComponents();
        setLocationRelativeTo(parent);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        scenario1 = new DrawStrategyPanel(knockoutDrawStrategy1);
        scenario2 = new DrawStrategyPanel(roundRobinDrawStrategy1);

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setAlwaysOnTop(true);
        setModalExclusionType(java.awt.Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
        setName("Form"); // NOI18N
        getContentPane().setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 20, 20));

        scenario1.setGenerate(this);
        getContentPane().add(scenario1);

        scenario2.setGenerate(this);
        getContentPane().add(scenario2);

        pack();
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private taikai.draws.DrawStrategyPanel scenario1;
    private taikai.draws.DrawStrategyPanel scenario2;
    // End of variables declaration//GEN-END:variables


    public abstract void onClose(DrawStrategy strategy);

    void close(DrawStrategy strategy) {
        this.setVisible(false);
        onClose(strategy);
        dispose();
    }
}
